default: test programs

PROGRAMS=wc

TESTS = $(wildcard *Test.hs) AllTests.hs

PROGRAM_SOURCES=$(addsuffix .hs, $(PROGRAMS))

PROGRAM_TARGETS=$(addprefix build/, $(PROGRAMS))

.PHONY: $(TESTS) test programs default depend clean

$(TESTS): %.hs:
	ghc -e "Test.HUnit.runTestTT $*.tests" $@

test: AllTests.hs

programs: $(PROGRAM_TARGETS)

# I hate separate 'make depend' steps.  Grr.
depend:
	./makedepend $(PROGRAM_SOURCES)

build/%.hi: build/%.o ;

build/%.o: %.hs
	ghc -c -ibuild -o $@ -ohi $(addsuffix .hi, $(basename $@)) $<

clean:
	rm -f build/*

-include programs.dep
